import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA
 * Description
 * User:华为
 * Date:2024/12/24
 * Time:17:33
 */
public class CardDemo {
    public static final String[] suits ={"♥","♠","♦","♣"};
    public List<Card> buyCard(){
        List<Card> CardList = new ArrayList<>();
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < 4; j++) {
                int rank = i;
                String suit = suits[j];
                Card card = new Card(rank,suit);
                CardList.add(card);
            }
        }
        return CardList;
    }

    public void shuffle(List<Card> cardList){
        Random random =new Random();
        for (int i = cardList.size()-1; i > 0  ; i--) {
            int index = random.nextInt(i);
            swap(cardList,index,i);
        }
    }

    private void swap(List<Card> list,int i ,int j){
        Card temp = list.get(i);
        list.set(i,list.get(j));
        list.set(j,temp);

    }

    public List<List<Card>> play(List<Card> cardList){
        List<Card> list1 = new ArrayList<>();
        List<Card> list2 = new ArrayList<>();
        List<Card> list3 = new ArrayList<>();

        List<List<Card>> list = new ArrayList<>();
        list.add(list1);
        list.add(list2);
        list.add(list3);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardList.remove(0);
                list.get(j).add(card);
            }
            
        }
        return list;

    }



}
